#!/usr/bin/env python  
#-*- coding:utf-8 _*-  
""" 
@author:hello_life 
@license: Apache Licence 
@file: lstm_parameters.py 
@time: 2022/04/30
@software: PyCharm 
description:
"""
import os
import datetime

import pickle
import torch

class Config():
    def __init__(self):
        #模型参数
        self.hidden_size=300

        #
        self.seq_len=20  #句子长度
        self.do_mask=True #
        self.batch_size=16
        self.steps=10
        self.device="cuda" if torch.cuda.is_available() else "cpu"
        self.mode="train"
        self.epochs=1
        self.clip_lr=0.01


        self.dir_path=os.path.abspath(os.getcwd())
        ##文件路径
        self.data_path=os.path.join(self.dir_path,"data","clue","train.json")  #原始数据，读取路径
        self.train_data_save_path=os.path.join(self.dir_path,"data","clue","train1.npz")  #处理后，数据存储路径
        self.test_data_save_path=os.path.join(self.dir_path,"data","clue","test1.npz")  #处理后，数据存储路径

        self.vocab_path=os.path.join(self.dir_path,"data","clue","vocab1.pkl")  #词表存储路径
        self.sougou_pretrian_embedding=os.path.join(self.dir_path,"data","sgns.literature.word") #搜狗的预训练权重
        self.pretrain_save_dir=os.path.join(self.dir_path,"data","clue","clue_embedding.npz")

        time1=datetime.datetime.now().strftime('%Y-%m-%d')
        time2 = datetime.datetime.now().strftime('%H-%M-%S')

        self.save_dir=os.path.join(self.dir_path,
                            "save_model",time1)  #存储文件夹路径
        self.save_path = os.path.join(self.save_dir, time2) #存储文件路劲


        ##
        with open(self.vocab_path,"rb") as f:
            self.vocab=pickle.load(f)

        #label_id
        self.label_id = {
    "O": 0,
    "B-address": 1,
    "B-book": 2,
    "B-company": 3,
    'B-game': 4,
    'B-government': 5,
    'B-movie': 6,
    'B-name': 7,
    'B-organization': 8,
    'B-position': 9,
    'B-scene': 10,
    "I-address": 11,
    "I-book": 12,
    "I-company": 13,
    'I-game': 14,
    'I-government': 15,
    'I-movie': 16,
    'I-name': 17,
    'I-organization': 18,
    'I-position': 19,
    'I-scene': 20,
    "S-address": 21,
    "S-book": 22,
    "S-company": 23,
    'S-game': 24,
    'S-government': 25,
    'S-movie': 26,
    'S-name': 27,
    'S-organization': 28,
    'S-position': 29,
    'S-scene': 30,
}
        self.label=["address","scene","position","name","movie","government","game",
                    "company","book"]
        self.num_class = len(self.label_id)
        self.id2label={_id:_label for _label,_id in list(self.label_id.items())}